com.cete.dynamicpdf
Class XYDestination
Example : This example shows how to create an outline for a PDF document using XYDestination.
import com.cete.dynamicpdf.*;
public class MyClass {
public static void main(String args[]) {
// Create a PDF Document
Document document = new Document();
// Add three blank pages
document.getPages().add( new Page( PageSize.LETTER ) );
document.getPages().add( new Page( PageSize.LETTER ) );
document.getPages().add( new Page( PageSize.LETTER ) );
// Add a top level outline and set properties
Outline outline1 = document.getOutlines().add( "Outline1" );
outline1.setStyle( TextStyle.BOLD );
outline1.setColor( new RgbColor( 255, 0, 0 ));
// Add child outlines
Outline outline1A = outline1.getChildOutlines().add( "Outline1A", new UrlAction( "http://www.mydomain.com" ) );
outline1A.setIsExpanded( false );
Outline outline1A1 = outline1A.getChildOutlines().add( "Outline1A1", new XYDestination( 2, 0, 0 ) );
Outline outline1A2 = outline1A.getChildOutlines().add( "Outline1A2", new ZoomDestination( 2, PageZoom.FIT_HEIGHT ) );
Outline outline1B = outline1.getChildOutlines().add( "Outline1B", new ZoomDestination( 2, PageZoom.FIT_WIDTH ) );
// Add a second top level outline
Outline outline2 = document.getOutlines().add( "Outline2", new XYDestination( 3, 0, 300 ) );
// Add a child outline
Outline outline2A = outline2.getChildOutlines().add( "Outline2A" );
// Save the PDF document
document.draw( "[physicalpath]/MyDocument.pdf" );
}
}